#include "led_driver.h"

LEDDriver::LEDDriver() {
    // 初始化LED数组
    memset(leds, 0, sizeof(leds));
}

LEDDriver::~LEDDriver() {
    // 析构函数
}

void LEDDriver::init() {
    // 初始化FastLED
    FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, LED_COUNT);
    FastLED.setBrightness(255); // 设置最大亮度
}

void LEDDriver::setPixel(uint32_t index, uint8_t r, uint8_t g, uint8_t b) {
    if (index < LED_COUNT) {
        leds[index] = CRGB(r, g, b);
    }
}

void LEDDriver::setAllPixels(uint8_t r, uint8_t g, uint8_t b) {
    fill_solid(leds, LED_COUNT, CRGB(r, g, b));
}

void LEDDriver::show() {
    FastLED.show();
}

void LEDDriver::clear() {
    fill_solid(leds, LED_COUNT, CRGB::Black);
    FastLED.show();
}